(function(){if(window["LHEPostForm"]){return}this.BX=this.BX||{};(function(e,t,i,n,r){"use strict";var a=function(){function e(t,i){babelHelpers.classCallCheck(this,e);babelHelpers.defineProperty(this,"id","SomeParser");babelHelpers.defineProperty(this,"buttonParams",{name:"Some parser name",iconClassName:"some-parser-class",disabledForTextarea:false,src:"/icon.png",toolbarSort:205});this.editor=t;this.htmlEditor=i;this.handler=this.handler.bind(this)}babelHelpers.createClass(e,[{key:"handler",value:function e(){}},{key:"parse",value:function e(t){return t}},{key:"unparse",value:function e(t,i){return""}},{key:"hasButton",value:function e(){return this.buttonParams!==null}},{key:"getButton",value:function e(){if(this.buttonParams===null){return null}return{id:this.id,name:this.buttonParams.name,iconClassName:this.buttonParams.iconClassName,disabledForTextarea:this.buttonParams.disabledForTextarea,src:this.buttonParams.src,toolbarSort:this.buttonParams.toolbarSort,handler:this.handler}}},{key:"getParser",value:function e(){var t=this;return{name:this.id,obj:{Parse:function e(i,n){return t.parse(n)},UnParse:this.unparse.bind(this)}}}}]);return e}();var o=function(e){babelHelpers.inherits(t,e);function t(){var e;var i;babelHelpers.classCallCheck(this,t);for(var n=arguments.length,a=new Array(n),o=0;o<n;o++){a[o]=arguments[o]}i=babelHelpers.possibleConstructorReturn(this,(e=babelHelpers.getPrototypeOf(t)).call.apply(e,[this].concat(a)));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(i),"id","spoiler");babelHelpers.defineProperty(babelHelpers.assertThisInitialized(i),"buttonParams",{name:r.Loc.getMessage("MPF_SPOILER"),iconClassName:"spoiler",disabledForTextarea:false,src:r.Loc.getMessage("MPF_TEMPLATE_FOLDER")+"/images/lhespoiler.svg",toolbarSort:205});return i}babelHelpers.createClass(t,[{key:"handler",value:function e(){var t;if(!this.htmlEditor.bbCode||!this.htmlEditor.synchro.IsFocusedOnTextarea()){t=this.htmlEditor.action.actions.formatBlock.exec("formatBlock","blockquote","bx-spoiler",false,{bxTagParams:{tag:"spoiler"}})}else{t=this.htmlEditor.action.actions.formatBbCode.exec("quote",{tag:"SPOILER"})}return t}},{key:"parse",value:function e(t,i){if(/\[spoiler(([^\]])*)\]/gi.test(t)){t=t.replace(/[\x01-\x02]/gi,"").replace(/\[spoiler([^\]]*)\]/gi,"\x01$1\x01").replace(/\[\/spoiler]/gi,"\x02");var n=/(?:\x01([^\x01]*)\x01)([^\x01-\x02]+)\x02/gi;while(t.match(n)){t=t.replace(n,function(e,t,i){t=t.replace(/^(="|='|=)/gi,"").replace(/("|')?$/gi,"");return'<blockquote class="bx-spoiler" id="'.concat(this.htmlEditor.SetBxTag(false,{tag:"spoiler"}),'" title="').concat(t,'">').concat(i,"</blockquote>")}.bind(this))}}t=t.replace(/\001([^\001]*)\001/gi,"[spoiler$1]").replace(/\002/gi,"[/spoiler]");return t}},{key:"unparse",value:function e(t,i){var n="";for(var r=0;r<i.node.childNodes.length;r++){n+=this.htmlEditor.bbParser.GetNodeHtml(i.node.childNodes[r])}n=n.trim();if(n!==""){return"[SPOILER"+(i.node.hasAttribute("title")?"="+i.node.getAttribute("title"):"")+"]"+n+"[/SPOILER]"}return""}}]);return t}(a);var s=function(e){babelHelpers.inherits(i,e);function i(e,n){var r;babelHelpers.classCallCheck(this,i);r=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).call(this,e,n));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(r),"id","postuser");babelHelpers.defineProperty(babelHelpers.assertThisInitialized(r),"buttonParams",null);t.EventEmitter.subscribe(n,"OnIframeKeydown",(function(e){var t=babelHelpers.slicedToArray(e.compatData,1),i=t[0];if(window.onKeyDownHandler){window.onKeyDownHandler(i,n,n.formID)}}));t.EventEmitter.subscribe(n,"OnIframeKeyup",(function(e){var t=babelHelpers.slicedToArray(e.compatData,1),i=t[0];if(window.onKeyUpHandler){window.onKeyUpHandler(i,n,n.formID)}}));t.EventEmitter.subscribe(n,"OnIframeClick",(function(){if(window["BXfpdStopMent"+n.formID]){window["BXfpdStopMent"+n.formID]()}}));t.EventEmitter.subscribe(n,"OnTextareaKeyup",(function(e){var t=babelHelpers.slicedToArray(e.compatData,1),i=t[0];if(n.textareaView&&n.textareaView.GetCursorPosition&&window.onTextareaKeyUpHandler){window.onTextareaKeyUpHandler(i,n,n.formID)}}));t.EventEmitter.subscribe(n,"OnTextareaKeydown",(function(e){var t=babelHelpers.slicedToArray(e.compatData,1),i=t[0];if(n.textareaView&&n.textareaView.GetCursorPosition&&window.onTextareaKeyDownHandler){window.onTextareaKeyDownHandler(i,n,n.formID)}}));return r}babelHelpers.createClass(i,[{key:"parse",value:function e(t,i){var n=this;t=t.replace(/\[USER\s*=\s*(\d+)\](.*?)\[\/USER\]/gi,(function(e,t,i){i=i.trim();if(i===""){return""}var r=n.htmlEditor.SetBxTag(false,{tag:n.id,userId:t,userName:i});return'<span id="'.concat(r,'" class="bxhtmled-metion">').concat(i,"</span>")})).replace(/\[PROJECT\s*=\s*(\d+)\](.*?)\[\/PROJECT\]/gi,(function(e,t,i){i=i.trim();if(i===""){return""}var r=n.htmlEditor.SetBxTag(false,{tag:n.id,projectId:t,projectName:i});return'<span id="'.concat(r,'" class="bxhtmled-metion">').concat(i,"</span>")})).replace(/\[DEPARTMENT\s*=\s*(\d+)\](.*?)\[\/DEPARTMENT\]/gi,(function(e,t,i){i=i.trim();if(i===""){return""}var r=n.htmlEditor.SetBxTag(false,{tag:n.id,departmentId:t,departmentName:i});return'<span id="'.concat(r,'" class="bxhtmled-metion">').concat(i,"</span>")}));return t}},{key:"unparse",value:function e(t,i){var n=this;var a="";i.node.childNodes.forEach((function(e){a+=n.htmlEditor.bbParser.GetNodeHtml(e)}));a=String(a).trim();var o="";if(r.Type.isStringFilled(a)){if(!r.Type.isUndefined(t.userId)){o="[USER=".concat(t.userId,"]").concat(a,"[/USER]")}else if(!r.Type.isUndefined(t.projectId)){o="[PROJECT=".concat(t.projectId,"]").concat(a,"[/PROJECT]")}else if(!r.Type.isUndefined(t.departmentId)){o="[DEPARTMENT=".concat(t.departmentId,"]").concat(a,"[/DEPARTMENT]")}}return o}}]);return i}(a);var l=function(){function e(i,n,r){babelHelpers.classCallCheck(this,e);babelHelpers.defineProperty(this,"actionPool",[]);this.cid=i;this.container=n;this.editor=r;t.EventEmitter.subscribe(r.getEventObject(),"onShowControllers",(function(e){var i=e.data;t.EventEmitter.emit(n.parentNode,"BFileDLoadFormController",new t.BaseEvent({compatData:[i]}))}));t.EventEmitter.subscribe(r.getEventObject(),"onCollectControllers",(function(e){e.data[i]={values:[]}}))}babelHelpers.createClass(e,[{key:"exec",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;if(t){this.actionPool.push(t)}if(this.isReady){try{var i;while((i=this.actionPool.shift())&&i){i.apply(this)}}catch(e){console.log("error in attachments controllers: ",e)}}}},{key:"getId",value:function e(){return this.cid}},{key:"getFieldName",value:function e(){return null}},{key:"reinitFrom",value:function e(t){var i=this;this.exec((function(){if(!i.getFieldName()){return}i.container.querySelector('inptut[name="'.concat(i.getFieldName(),'"]')).forEach((function(e){e.parentNode.removeChild(e)}))}))}},{key:"isReady",get:function e(){return true}}]);return e}();var d=function(e){babelHelpers.inherits(i,e);function i(e,n,r){var a;babelHelpers.classCallCheck(this,i);a=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).call(this,e,n,r));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(a),"diskUfUploader",null);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(a),"diskUfHandler",null);var o=function e(i){a.diskUfUploader=i;a.exec();var n=function e(i){t.EventEmitter.emit(r.getEventObject(),"onUploadsHasBeenChanged",i)};t.EventEmitter.subscribe(a.diskUfUploader,"onFileIsInited",n);t.EventEmitter.subscribe(a.diskUfUploader,"ChangeFileInput",n)};if(BX.UploaderManager.getById(e)){o(BX.UploaderManager.getById(e))}t.EventEmitter.subscribeOnce(n.parentNode,"DiskDLoadFormControllerInit",(function(t){var i=babelHelpers.slicedToArray(t.compatData,1),n=i[0];a.diskUfHandler=n;if(e===n.CID&&!a.diskUfUploader){o(n.agent)}}));t.EventEmitter.subscribe(r.getEventObject(),"onShowControllers",(function(e){var i=e.data;t.EventEmitter.emit(n.parentNode,"DiskLoadFormController",new t.BaseEvent({compatData:[i]}))}));return a}babelHelpers.createClass(i,[{key:"getFieldName",value:function e(){if(this.diskUfHandler){return this.diskUfHandler.params.controlName}return null}},{key:"reinitFrom",value:function e(t){var i=this;this.exec((function(){if(!i.getFieldName()){return}Array.from(i.container.querySelectorAll('inptut[name="'.concat(i.getFieldName(),'"]'))).forEach((function(e){e.parentNode.removeChild(e)}));var e=null;for(var n in t){if(t.hasOwnProperty(n)&&t[n]&&t[n]["USER_TYPE_ID"]==="disk_file"&&t[n]["FIELD_NAME"]===i.getFieldName()){e=t[n]["VALUE"]}}if(e){var r={};e.forEach((function(e){var t=document.querySelector("#disk-attach-"+e);if(t.tagName!=="A"){t=t.querySelector("img")}if(t){r["E"+e]={type:"file",id:e,name:t.getAttribute("data-bx-title")||t.getAttribute("data-title"),size:t.getAttribute("data-bx-size")||"",sizeInt:t.getAttribute("data-bx-size")||"",width:t.getAttribute("data-bx-width"),height:t.getAttribute("data-bx-height"),storage:"disk",previewUrl:t.tagName==="A"?"":t.getAttribute("data-bx-src")||t.getAttribute("data-src"),fileId:t.getAttribute("bx-attach-file-id")};if(t.hasAttribute("bx-attach-xml-id"))r["E"+e]["xmlId"]=t.getAttribute("bx-attach-xml-id");if(t.hasAttribute("bx-attach-file-type"))r["E"+e]["fileType"]=t.getAttribute("bx-attach-file-type")}}));i.diskUfHandler.selectFile({},{},r)}}))}},{key:"isReady",get:function e(){return!!this.diskUfUploader}}]);return i}(l);var c;var u=function(e){babelHelpers.inherits(i,e);function i(e,n){var a;babelHelpers.classCallCheck(this,i);a=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).call(this,e,n));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(a),"id","uploadfile");babelHelpers.defineProperty(babelHelpers.assertThisInitialized(a),"buttonParams",null);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(a),"regexp",/\[FILE ID=((?:\s|\S)*?)?\]/gi);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(a),"values",new Map);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(a),"controllers",new Map);a.checkButtonsDebounced=r.Runtime.debounce(a.checkButtons,500,babelHelpers.assertThisInitialized(a));a.init();t.EventEmitter.subscribe(e.getEditor(),"OnContentChanged",a.checkButtons.bind(babelHelpers.assertThisInitialized(a)));t.EventEmitter.subscribe(e.getEventObject(),"onReinitializeBefore",(function(e){var t=babelHelpers.slicedToArray(e.data,2),i=t[0],n=t[1];a.reinit(i,n)}));return a}babelHelpers.createClass(i,[{key:"init",value:function e(){var i=this;Array.from(this.editor.getContainer().querySelectorAll(".file-selectdialog")).forEach((function(e,n){var r=e.id.replace("file-selectdialog-","");var a=i.controllers.get(r);if(!a){a=new l(r,e,i.editor);t.EventEmitter.subscribe(e.parentNode,"OnFileUploadSuccess",(function(t){var n=babelHelpers.slicedToArray(t.data,2),a=n[0].element_id,o=n[1],s=o.id,l=o.doc_prefix,d=o.CID;if(r===s){var c=document.querySelector("#"+i.editor.getFormId())?document.querySelector("#"+i.editor.getFormId()).querySelector("#upload-cid"):null;if(c){c.value=d}var u=i.parseFile(e.querySelector("#"+l+a)),f=babelHelpers.slicedToArray(u,2),p=f[0],h=f[1];i.values.set(p,h)}}));t.EventEmitter.subscribe(e.parentNode,"OnFileUploadRemove",(function(e){var t=babelHelpers.slicedToArray(e.compatData,2),n=t[0],a=t[1].id;if(r===a&&i.values.has(n)){i.values["delete"](n);i.deleteFile([n])}}));if(n===0){t.EventEmitter.subscribe(i.editor.getEventObject(),"onFilesHaveCaught",(function(e){e.stopImmediatePropagation();if(window["BfileFD"+r]){window["BfileFD"+r].agent.UploadDroppedFiles(babelHelpers.toConsumableArray(e.getData()))}}))}}if(e.querySelector("table.files-list")){Array.from(e.querySelector("table.files-list").querySelectorAll("tr")).forEach((function(e){var t=i.parseFile(e),n=babelHelpers.slicedToArray(t,2),r=n[0],a=n[1];i.values.set(r,a)}))}}))}},{key:"parseFile",value:function e(t){var i=this;var n=t.id.replace("wd-doc","");var a={id:n,name:t.querySelector('[data-role="name"]')?t.querySelector('[data-role="name"]').innerHTML:t.querySelector("span.f-wrap").innerHTML,node:t,buttonNode:t.querySelector('[data-role="button-insert"]'),image:{src:null,lowsrc:null,width:null,height:null}};var o=function e(){i.insertFile(n,t)};var s=t.querySelector(".f-wrap");if(s){s.addEventListener("click",o);s.style.cursor="pointer";s.title=r.Loc.getMessage("MPF_FILE")}var l=t.querySelector("img");if(l){l.addEventListener("click",o);l.title=r.Loc.getMessage("MPF_FILE");l.style.cursor="pointer";a.image.lowsrc=l.lowsrc||l.src;a.image.src=l.rel||l.src;a.image.width=l.getAttribute("data-bx-full-width");a.image.height=l.getAttribute("data-bx-full-height")}if(t instanceof HTMLTableRowElement&&t.querySelector(".files-info")){if(!a.buttonNode){a.buttonNode=r.Tag.render(c||(c=babelHelpers.taggedTemplateLiteral(['\n<span type="button" onclick="','" data-role="button-insert" class="insert-btn">\n\t<span data-role="insert-btn" class="insert-btn-text">','</span>\n\t<span data-role="in-text-btn" class="insert-btn-text">',"</span>\n</span>"])),o,r.Loc.getMessage("MPF_FILE_INSERT_IN_TEXT"),r.Loc.getMessage("MPF_FILE_IN_TEXT"));t.querySelector(".files-info").appendChild(a.buttonNode);this.checkButtonsDebounced()}}return[n,a]}},{key:"buildHTML",value:function e(t,i){var n=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;var r=this.htmlEditor.SetBxTag(false,{tag:this.id,fileId:t});var a='<span data-bx-file-id="'.concat(t,'" id="').concat(r,'" style="color: #2067B0; border-bottom: 1px dashed #2067B0; margin:0 2px;">').concat(i.name,"</span>");if(i.image.src){var o=[];if(n){o.push('style="width:'.concat(n.width,"px;height:").concat(n.height,'px;"'))}else if(i.image.width&&i.image.height){o.push('style="width:'.concat(i.image.width,"px;height:").concat(i.image.height,'px;" '));o.push("onload=\"this.style.width='auto';this.style.height='auto';\"")}a='<img style="max-width: 90%;"  data-bx-file-id="'.concat(t,'" id="').concat(r,'" src="').concat(i.image.src,'" lowsrc="').concat(i.image.lowsrc,'" ').concat(o.join(" "),"/>")}return a}},{key:"buildText",value:function e(t,i){return"[FILE ID=".concat(t).concat(i||"","]")}},{key:"insertFile",value:function e(i,n){var r=this.values.get(String(i));if(r){t.EventEmitter.emit(this.editor.getEventObject(),"OnInsertContent",[this.buildText(i),this.buildHTML(i,r)])}}},{key:"deleteFile",value:function e(t){var i=this.htmlEditor.GetContent();if(this.htmlEditor.GetViewMode()==="wysiwyg"){var n=this.htmlEditor.GetIframeDoc();for(var r in this.htmlEditor.bxTags){if(this.htmlEditor.bxTags.hasOwnProperty(r)&&babelHelpers["typeof"](this.htmlEditor.bxTags[r])==="object"&&this.htmlEditor.bxTags[r]["tag"]===this.id&&t.indexOf(String(this.htmlEditor.bxTags[r]["fileId"]))>=0&&n.getElementById(r)){var a=n.getElementById(r);a.parentNode.removeChild(a)}}this.htmlEditor.SaveContent()}else{var o=i.replace(this.regexp,(function(e,i){return t.indexOf(i)>=0?"":e}));this.htmlEditor.SetContent(o);this.htmlEditor.Focus()}}},{key:"checkButtons",value:function e(t){var i=t?t.compatData[0]:this.htmlEditor.GetContent();var n=babelHelpers.toConsumableArray(i.matchAll(this.regexp)).map((function(e){var t=babelHelpers.slicedToArray(e,2),i=t[0],n=t[1];return n}));this.values.forEach((function(e,t){if(!e.buttonNode){return}var i=n.indexOf(t)>=0;if(i===true&&e.buttonNode.className!=="insert-text"){e.buttonNode.className="insert-text";e.buttonNode.querySelector('[data-role="insert-btn"]').style.display="none";e.buttonNode.querySelector('[data-role="in-text-btn"]').style.display=""}else if(i!==true&&e.buttonNode.className!=="insert-btn"){e.buttonNode.className="insert-btn";e.buttonNode.querySelector('[data-role="insert-btn"]').style.display="";e.buttonNode.querySelector('[data-role="in-text-btn"]').style.display="none"}}))}},{key:"reinit",value:function e(t,i){this.values.forEach((function(e,t){if(e.node&&e.node.parentNode){e.node.parentNode.removeChild(e.node)}}));this.values.clear();this.controllers.forEach((function(e){e.reinitFrom(i)}))}},{key:"parse",value:function e(t){if(!this.regexp.test(t)){return t}t=t.replace(this.regexp,function(e,t,i,n){if(this.values.has(t)){return this.buildHTML(t,this.values.get(t),i>0&&n>0?{width:i,height:n}:null)}return e}.bind(this));return t}},{key:"unparse",value:function e(t,i){var n=i.node;var r=parseInt(n.hasAttribute("width")?n.getAttribute("width"):0);var a=parseInt(n.hasAttribute("height")?n.getAttribute("height"):0);var o="";if(r>0&&a>0){o=" WIDTH="+r+" HEIGHT="+a}var s=n.getAttribute("data-bx-file-id");return this.buildText(s,o)}}]);return i}(a);var f=function(e){babelHelpers.inherits(i,e);function i(e,n){var r;babelHelpers.classCallCheck(this,i);r=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).call(this,e,n));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(r),"id","uploadimage");babelHelpers.defineProperty(babelHelpers.assertThisInitialized(r),"buttonParams",null);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(r),"regexp",/\[IMAGE ID=((?:\s|\S)*?)?\]/gi);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(r),"values",new Map);babelHelpers.defineProperty(babelHelpers.assertThisInitialized(r),"controllers",new Map);r.init();console.log("PostImage: ");t.EventEmitter.subscribe(e.getEventObject(),"onReinitializeBefore",(function(e){var t=babelHelpers.slicedToArray(e.data,2),i=t[0],n=t[1];r.reinit(i,n)}));return r}babelHelpers.createClass(i,[{key:"init",value:function e(){var i=this;Array.from(this.editor.getContainer().querySelectorAll(".file-selectdialog")).forEach((function(e){var n=e.id.replace("file-selectdialog-","");var r=i.controllers.get(n);if(!r){r=new l(n,e,i.editor);t.EventEmitter.subscribe(e.parentNode,"OnFileUploadSuccess",(function(t){var r=babelHelpers.slicedToArray(t.data,2),a=r[0].element_id,o=r[1],s=o.id,l=o.doc_prefix,d=o.CID;if(n===s){var c=document.querySelector("#"+i.editor.getFormId())?document.querySelector("#"+i.editor.getFormId()).querySelector("#upload-cid"):null;if(c){c.value=d}var u=i.parseFile(e.querySelector("#"+l+a)),f=babelHelpers.slicedToArray(u,2),p=f[0],h=f[1];i.values.set(p,h)}}));t.EventEmitter.subscribe(e.parentNode,"OnFileUploadRemove",(function(e){var t=babelHelpers.slicedToArray(e.compatData,2),r=t[0],a=t[1].id;if(n===a&&i.values.has(r)){i.values["delete"](r)}}))}if(e.querySelector("table.files-list")){Array.from(e.querySelector("table.files-list").querySelectorAll("tr")).forEach((function(e){var t=i.parseFile(e),n=babelHelpers.slicedToArray(t,2),r=n[0],a=n[1];i.values.set(r,a)}))}}))}},{key:"parseFile",value:function e(t){var i=t.id.replace("wd-doc","");var n={id:i,name:t.querySelector('[data-role="name"]')?t.querySelector('[data-role="name"]').innerHTML:t.querySelector("span.f-wrap").innerHTML,node:t,image:{src:null,lowsrc:null,width:null,height:null}};return[i,n]}},{key:"reinit",value:function e(t,i){this.values.forEach((function(e,t){if(e.node&&e.node.parentNode){e.node.parentNode.removeChild(e.node)}}));this.values.clear();this.controllers.forEach((function(e){e.reinitFrom(i)}))}},{key:"parse",value:function e(t){return t}},{key:"unparse",value:function e(t,i){var n=i.node;return""}}]);return i}(a);var p;var h=function(e){babelHelpers.inherits(i,e);function i(){var e;var t;babelHelpers.classCallCheck(this,i);for(var n=arguments.length,r=new Array(n),a=0;a<n;a++){r[a]=arguments[a]}t=babelHelpers.possibleConstructorReturn(this,(e=babelHelpers.getPrototypeOf(i)).call.apply(e,[this].concat(r)));babelHelpers.defineProperty(babelHelpers.assertThisInitialized(t),"id","diskfile");babelHelpers.defineProperty(babelHelpers.assertThisInitialized(t),"regexp",/\[(?:DOCUMENT ID|DISK FILE ID)=([n0-9]+)\]/gi);return t}babelHelpers.createClass(i,[{key:"init",value:function e(){var i=this;Array.from(this.editor.getContainer().querySelectorAll(".diskuf-selectdialog")).forEach((function(e,n){var r=e.id.replace("diskuf-selectdialog-","");var a=i.controllers.get(r);if(!a){a=new d(r,e,i.editor);i.controllers.set(r,a);t.EventEmitter.subscribe(e.parentNode,"OnFileUploadSuccess",(function(t){var n=babelHelpers.slicedToArray(t.data,3),r=n[0].element_id,o=n[1].CID,s=n[2];if(a.getId()!==o||i.values.has(r)){return}var l=i.parseFile(e.querySelector("#disk-edit-attach"+r)),d=babelHelpers.slicedToArray(l,3),c=d[0],u=d[1],f=d[2];i.values.set(c,f);if(c!==u){i.values.set(u,f)}if(s&&s["insertImageAfterUpload"]&&f.image.src){i.insertFile(c,f.node)}}));t.EventEmitter.subscribe(e.parentNode,"OnFileUploadRemove",(function(e){var t=babelHelpers.slicedToArray(e.compatData,2),n=t[0],r=t[1].CID;if(a.getId()===r&&i.values.has(n)){var o=i.values.get(n);i.values["delete"](o.id);i.values["delete"](o.fileId);i.deleteFile([o.id,o.fileId])}}));t.EventEmitter.subscribe(e.parentNode,"OnFileUploadFailed",(function(e){var t=babelHelpers.slicedToArray(e.compatData,3),n=t[0],r=t[1].CID,o=t[2];if(a.getId()===r&&o&&o["referrerToEditor"]){BX.onCustomEvent(o["referrerToEditor"],"OnImageDataUriCaughtFailed",[]);BX.onCustomEvent(i.editor,"OnImageDataUriCaughtFailed",[o["referrerToEditor"]])}}));if(n===0){b(i,a,e,i.editor);m(i,a,e,i.editor);t.EventEmitter.subscribe(i.editor.getEventObject(),"onFilesHaveCaught",(function(e){e.stopImmediatePropagation();a.diskUfUploader.onChange(babelHelpers.toConsumableArray(e.getData()))}))}}if(e.querySelector("table.files-list")){Array.from(e.querySelector("table.files-list").querySelectorAll("tr")).forEach((function(e){var t=i.parseFile(e),n=babelHelpers.slicedToArray(t,3),r=n[0],a=n[1],o=n[2];i.values.set(r,o);if(r!==a){i.values.set(a,o)}}))}}))}},{key:"parseFile",value:function e(t){var i=this;var n=String(t.id.replace("disk-edit-attach",""));var a={id:n,name:t.querySelector('[data-role="name"]')?t.querySelector('[data-role="name"]').innerHTML:t.querySelector("span.f-wrap").innerHTML,fileId:t.getAttribute("bx-attach-file-id"),node:t,buttonNode:t.querySelector('[data-role="button-insert"]'),image:{src:null,lowsrc:null,width:null,height:null}};var o=t.querySelector(".f-wrap");var s=function e(){i.insertFile(n,t)};if(o){o.addEventListener("click",s);o.style.cursor="pointer";o.title=r.Loc.getMessage("MPF_FILE")}var l=t.querySelector("img.files-preview");if(l&&(l.src.indexOf("bitrix/tools/disk/uf.php")>=0||l.src.indexOf("/disk/showFile/")>=0)){l.addEventListener("click",s);l.title=r.Loc.getMessage("MPF_FILE");l.style.cursor="pointer";a.image.lowsrc=l.lowsrc||l.src;a.image.src=(l.rel||l.getAttribute("data-bx-src")||l.src).replace(/&(width|height)=\d+/gi,"");var d=function e(){a.image.width=l.getAttribute("data-bx-full-width");a.image.height=l.getAttribute("data-bx-full-height")};l.addEventListener("load",d);if(l.complete){d()}}if(t instanceof HTMLTableRowElement&&!a.buttonNode){a.buttonNode=r.Tag.render(p||(p=babelHelpers.taggedTemplateLiteral(['\n<span class="insert-btn" data-role="button-insert" onclick="','">\n\t<span data-role="insert-btn" class="insert-btn-text">','</span>\n\t<span data-role="in-text-btn" class="insert-btn-text" style="display: none;">',"</span>\n</span>"])),s,r.Loc.getMessage("MPF_FILE_INSERT_IN_TEXT"),r.Loc.getMessage("MPF_FILE_IN_TEXT"));setTimeout((function(){if(t.querySelector(".files-info")){t.querySelector(".files-info").appendChild(a.buttonNode);i.checkButtonsDebounced()}}))}return[n,a.fileId,a]}},{key:"buildText",value:function e(t,i){return"[DISK FILE ID=".concat(t).concat(i||"","]")}}]);return i}(u);function b(e,i,n,r){t.EventEmitter.subscribe(r.getEventObject(),"OnVideoHasCaught",(function(r){var a=r.getData();var o=function i(r){var o=babelHelpers.slicedToArray(r.data,3),s=o[0].element_id;babelHelpers.objectDestructuringEmpty(o[1]);var l=o[2];if(a===l&&e.values.has(s)){t.EventEmitter.unsubscribe(n.parentNode,"OnFileUploadSuccess",i);e.insertFile(s,e.values.get(s).node)}};t.EventEmitter.subscribe(n.parentNode,"OnFileUploadSuccess",o);i.exec((function(){i.diskUfUploader.onChange([a])}));r.stopImmediatePropagation()}))}function m(e,i,n,r){t.EventEmitter.subscribe(r.getEventObject(),"OnImageHasCaught",(function(r){r.stopImmediatePropagation();var a=r.getData();return new Promise((function(o,s){var l=function i(r){var s=babelHelpers.slicedToArray(r.data,3),l=s[0].element_id;babelHelpers.objectDestructuringEmpty(s[1]);var c=s[2];if(a===c&&e.values.has(l)){t.EventEmitter.unsubscribe(n.parentNode,"OnFileUploadSuccess",i);t.EventEmitter.unsubscribe(n.parentNode,"OnFileUploadFailed",d);var u=e.values.get(l);var f=e.buildHTML(l,u);o({image:u.image,html:f})}};var d=function e(i){var r=babelHelpers.slicedToArray(i.data,3),o=r[0];babelHelpers.objectDestructuringEmpty(r[1]);var d=r[2];if(a===d){t.EventEmitter.unsubscribe(n.parentNode,"OnFileUploadSuccess",l);t.EventEmitter.unsubscribe(n.parentNode,"OnFileUploadFailed",e);s()}};t.EventEmitter.subscribe(n.parentNode,"OnFileUploadSuccess",l);t.EventEmitter.subscribe(n.parentNode,"OnFileUploadFailed",d);i.exec((function(){i.diskUfUploader.onChange([r.getData()])}))}))}))}function v(e,t,i){if(e==="Spoiler"){return new o(t,i)}else if(e==="MentionUser"){return new s(t,i)}else if(e==="UploadImage"){return new f(t,i)}else if(e==="UploadFile"){return new u(t,i)}else if(babelHelpers["typeof"](e)==="object"&&e["disk_file"]){return new h(t,i)}return null}function E(e,t){if(!t){return}BX.addCustomEvent(t,"onAutoSavePrepare",(function(t){t.FORM.setAttribute("bx-lhe-autosave-prepared","Y");setTimeout((function(){BX.addCustomEvent(e,"OnContentChanged",(function(e){t["mpfTextContent"]=e;t.Init()}))}),1500)}));BX.addCustomEvent(t,"onAutoSave",(function(e,t){if(BX.type.isNotEmptyString(e["mpfTextContent"]))t["text"]=e["mpfTextContent"]}));BX.addCustomEvent(t,"onAutoSaveRestore",(function(t,i){if(i["text"]&&/[^\s]+/gi.test(i["text"])){e.CheckAndReInit(i["text"])}}));if(t.hasAttribute("bx-lhe-autosave-prepared")&&t.BXAUTOSAVE){t.removeAttribute("bx-lhe-autosave-prepared");setTimeout(t.BXAUTOSAVE.Prepare,100)}}function g(e,t,i){var n=false;if(i.showPanelEditor!==true&&i.showPanelEditor!==false){i.showPanelEditor=!t.toolbar.IsShown();n=true}e.exec((function(){var n=e.getContainer().querySelector('[data-bx-role="button-show-panel-editor"]');if(i.showPanelEditor){t.dom.toolbarCont.style.opacity="inherit";t.toolbar.Show();if(n){n.classList.add("feed-add-post-form-btn-active")}}else{t.toolbar.Hide();if(n){n.classList.remove("feed-add-post-form-btn-active")}}}));if(n!==false){BX.userOptions.save("main.post.form","postEdit","showBBCode",i.showPanelEditor?"Y":"N")}}function y(e,t){if(!(t.urlPreviewId&&window["BXUrlPreview"]&&BX(t.urlPreviewId))){return}var i=new BXUrlPreview(BX(t.urlPreviewId));var n=function e(t){i.attachUrlPreview({url:t})};var r=function e(t,n,r,a){if(n==="createLink"&&BX.type.isPlainObject(a)&&a.hasOwnProperty("href")){i.attachUrlPreview({url:a.href})}};BX.addCustomEvent(e,"OnAfterUrlConvert",n);BX.addCustomEvent(e,"OnAfterLinkInserted",n);BX.addCustomEvent(e,"OnBeforeCommandExec",r);BX.addCustomEvent(e,"OnReinitialize",(function(e,t){i.detachUrlPreview();var n;for(var r in t){if(t.hasOwnProperty(r)&&t[r].hasOwnProperty("USER_TYPE_ID")&&t[r]["USER_TYPE_ID"]==="url_preview"){n=t[r]["VALUE"];break}}if(n){i.attachUrlPreview({id:n})}}))}function w(e,t){e.exec((function(){t.contextMenu.items["postimage"]=t.contextMenu.items["postdocument"]=t.contextMenu.items["postfile"]=[{TEXT:r.Loc.getMessage("BXEdDelFromText"),bbMode:true,ACTION:function e(){var i=t.contextMenu.GetTargetItem("postimage");if(!i)i=t.contextMenu.GetTargetItem("postdocument");if(!i)i=t.contextMenu.GetTargetItem("postfile");if(i&&i.element){t.selection.RemoveNode(i.element)}t.contextMenu.Hide()}}];if(t.toolbar.controls&&t.toolbar.controls.FontSelector){t.toolbar.controls.FontSelector.SetWidth(45)}}))}function B(e){var i=document.querySelector("#lhe_button_submit_"+e.getFormId());if(i){i.addEventListener("click",(function(i){t.EventEmitter.emit(e.getEventObject(),"OnButtonClick",["submit"]);i.preventDefault();i.stopPropagation()}))}var n=document.querySelector("#lhe_button_cancel_"+e.getFormId());if(n){n.addEventListener("click",(function(i){t.EventEmitter.emit(e.getEventObject(),"OnButtonClick",["cancel"]);i.preventDefault();i.stopPropagation()}))}}function I(e,i){var n=e.getContainer().querySelector('[data-bx-role="toolbar"]');if(n.querySelector('[data-id="file"]')){var r=n.querySelector('[data-id="file"]');if(r){r.addEventListener("click",(function(){t.EventEmitter.emit(e.getEventObject(),"onShowControllers",r.hasAttribute("data-bx-button-status")?"hide":"show")}));t.EventEmitter.subscribe(e.getEventObject(),"onShowControllers",(function(e){var t=e.data;if(t.toString()==="show"){r.setAttribute("data-bx-button-status","active")}else{r.removeAttribute("data-bx-button-status")}}));r.setAttribute("data-bx-files-count",0);t.EventEmitter.subscribe(e.getEventObject(),"onShowControllers:File:Increment",(function(e){var t=e.data;var i=t>0?t:1;var n=Math.max(parseInt(r.getAttribute("data-bx-files-count")||0)+i,0);if(n>0){if(!r["counterObject"]){r["counterObject"]=new BX.UI.Counter({value:n,color:BX.UI.Counter.Color.GRAY,animate:true});var a=r.querySelector("span");a.appendChild(r["counterObject"].getContainer())}else{r["counterObject"].update(n)}}r.setAttribute("data-bx-files-count",n)}));t.EventEmitter.subscribe(e.getEventObject(),"onShowControllers:File:Decrement",(function(e){var t=e.data;var i=t>0?t:1;var n=Math.max(parseInt(r.getAttribute("data-bx-files-count")||0)-i,0);r.setAttribute("data-bx-files-count",n);if(r["counterObject"]){r["counterObject"].update(n)}}))}}if(n.querySelector('[data-id="search-tag"]')){window["BXPostFormTags_"+e.getFormId()]=new BXPostFormTags(e.getFormId(),n.querySelector('[data-id="search-tag"]'))}if(n.querySelector('[data-id="create-link"]')){n.querySelector('[data-id="create-link"]').addEventListener("click",(function(e){i.toolbar.controls.InsertLink.OnClick(e)}))}if(n.querySelector('[data-id="video"]')){n.querySelector('[data-id="video"]').addEventListener("click",(function(e){i.toolbar.controls.InsertVideo.OnClick(e)}))}if(n.querySelector('[data-id="quote"]')){var a=n.querySelector('[data-id="quote"]');a.setAttribute("data-bx-type","action");a.setAttribute("data-bx-action","quote");a.addEventListener("mousedown",(function(e){i.toolbar.controls.Quote.OnMouseDown.apply(i.toolbar.controls.Quote,[e]);i.CheckCommand(a)}))}if(e.getContainer().querySelector('[data-bx-role="button-show-panel-editor"]')){e.getContainer().querySelector('[data-bx-role="button-show-panel-editor"]').addEventListener("click",(function(){e.showPanelEditor()}))}}var S;var C;function T(e,t){if(!C){C=new IntersectionObserver((function(e){e.forEach((function(e){if(e.isIntersecting){C.unobserve(e.target);var t=e.target.observedCallback;delete e.target.observedCallback;setTimeout(t)}}))}),{threshold:0})}e.observedCallback=t;C.observe(e)}var P=0;var O=function(){function e(t,i){babelHelpers.classCallCheck(this,e);this.container=i.querySelector('[data-bx-role="toolbar"]');this.adjustMorePosition=this.adjustMorePosition.bind(this);this.moreItem=i.querySelector('[data-bx-role="toolbar-item-more"]');this.moreItem.addEventListener("click",this.showSubmenu.bind(this));T(this.container,this.adjustMorePosition);window.addEventListener("resize",this.adjustMorePosition)}babelHelpers.createClass(e,[{key:"insertAfter",value:function e(t,i){if(!r.Type.isElementNode(t["BODY"])&&!r.Type.isStringFilled(t["BODY"])){return}var n=r.Tag.render(S||(S=babelHelpers.taggedTemplateLiteral(['<div class="main-post-form-toolbar-button" data-bx-role="toolbar-item"></div>'])));if(r.Type.isElementNode(t["BODY"])){n.appendChild(t["BODY"])}else{n.innerHTML=t["BODY"]}if(t["ID"]){n.setAttribute("data-id",t["ID"])}if(i!==null){var a=false;var o=null;Array.from(this.container.querySelectorAll('[data-bx-role="toolbar-item"]')).forEach((function(e){if(a===true&&o===null){o=e}else if(a===false&&e&&e.dataset&&e.dataset.id===i){a=true}}));if(o){o.parentNode.insertBefore(n,o)}}if(!n.parentNode){this.container.appendChild(n)}this.adjustMorePosition()}},{key:"getItems",value:function e(){return Array.from(this.container.querySelectorAll('[data-bx-role="toolbar-item"]'))}},{key:"getVisibleItems",value:function e(){var t=this;var i=[];Array.from(this.container.querySelectorAll('[data-bx-role="toolbar-item"]')).forEach((function(e){if(e.offsetTop>t.container.clientHeight/2){i.push(e)}}));return i}},{key:"getHiddenItems",value:function e(){var t=[];Array.from(this.container.querySelectorAll('[data-bx-role="toolbar-item"]')).forEach((function(e){if(e.offsetTop>0){t.push(e)}}));return t}},{key:"adjustMorePosition",value:function e(){var t=this.getVisibleItems().length;if(t<=0||t>=this.getItems().length){this.moreItem.style.display="none"}else{this.moreItem.style.display=""}}},{key:"getPopup",value:function e(){var t=this;if(!this.popup){this.popup=n.PopupManager.create({id:"main_post_form_toolbar_"+P++,className:"main-post-form-toolbar-popup",cacheable:false,content:this.getPopupContainer(),closeByEsc:true,autoHide:true,angle:true,bindElement:this.moreItem,offsetTop:-5,offsetLeft:5,events:{onClose:function e(){Array.from(t.getPopupContainer().querySelectorAll('[data-bx-role="toolbar-item"]')).forEach((function(e){t.container.appendChild(e)}));delete t.popup}}})}return this.popup}},{key:"getPopupContainer",value:function e(){if(!this.popupContainer){this.popupContainer=document.createElement("DIV")}return this.popupContainer}},{key:"showSubmenu",value:function e(){var t=this;var i=this.getHiddenItems();if(i.length<=0){return}i.forEach((function(e){t.getPopupContainer().appendChild(e)}));this.getPopup().show()}}]);return e}();var x=function(){function e(){babelHelpers.classCallCheck(this,e)}babelHelpers.createClass(e,null,[{key:"showPopup",value:function e(t){var i=n.PopupManager.getPopupById(this.getPopupId());if(!i){i=new n.Popup(this.getPopupId(),null,{content:this.getTasksLimitPopupContent(),lightShadow:false,offsetLeft:20,autoHide:false,angle:{position:"bottom"},closeByEsc:false,closeIcon:true})}i.setBindElement(t.bindPosition);i.show()}},{key:"getPopupId",value:function e(){return"bx-post-mention-tasks-limit-popup"}},{key:"getTasksLimitPopupContent",value:function e(){return r.Dom.create("DIV",{style:{width:"400px",padding:"10px"},children:[r.Dom.create("SPAN",{html:r.Loc.getMessage("MPF_MENTION_TASKS_LIMIT").replace("#A_BEGIN#",'<a href="javascript:void(0);" onclick="BX.Main.PostFormTasksLimit.onClickTasksLimitPopupSlider();">').replace("#A_END#","</a>")})]})}},{key:"onClickTasksLimitPopupSlider",value:function e(){this.hidePopup();BX.UI.InfoHelper.show("limit_tasks_observers_participants",{isLimit:true,limitAnalyticsLabels:{module:"tasks",source:"postForm",subject:"auditor"}})}},{key:"hidePopup",value:function e(){var t=n.PopupManager.getPopupById(this.getPopupId());if(t){t.close()}}}]);return e}();function X(e,t,i){H(e,t);k(i,"get");return F(e,i)}function k(e,t){if(e===undefined){throw new TypeError("attempted to "+t+" private static field before its declaration")}}function H(e,t){if(e!==t){throw new TypeError("Private static access of wrong provenance")}}function F(e,t){if(t.get){return t.get.call(e)}return t.value}var A=function(){function e(i,n){var a=this;babelHelpers.classCallCheck(this,e);babelHelpers.defineProperty(this,"jobs",new Map);babelHelpers.defineProperty(this,"editorParams",{height:100,ctrlEnterHandler:null,parsers:null,showPanelEditor:false,lazyLoad:true,urlPreviewId:null,tasksLimitExceeded:false});babelHelpers.defineProperty(this,"actionQueue",[]);this.id=i["id"];this.name=i["name"];this.formId=i["formId"];this.eventNode=i.eventNode||document.querySelector("#div"+(this.name||this.id));this.eventNode.dataset.bxHtmlEditable="Y";this.formEntityType=null;e.repo.set(this.getId(),this);if(!r.Type.isArray(n.parsers)&&r.Type.isPlainObject(n.parsers)){n.parsers=Object.values(n.parsers)}this.setEditorParams(n);this.bindEvents(window["BXHtmlEditor"]?window["BXHtmlEditor"].Get(this.getId()):null);this.toolbar=new O(this.getEventObject(),this.getContainer());this.inited=true;if(this.name!==null){window[this.name]=this}BX.onCustomEvent(this,"onInitialized",[this,this.getFormId()]);t.EventEmitter.subscribe(this.getEventObject(),"OnFileUploadSuccess",(function(e){var t=e.compatData;BX.onCustomEvent(a.getEventObject(),"onFileIsAdded",t)}));t.EventEmitter.subscribe(this.getEventObject(),"onBusy",(function(e){var i=e.data;if(a.jobs.size<=0){t.EventEmitter.emit(a.getEventObject(),"onLHEIsBusy")}a.jobs.set(i,(a.jobs.get(i)||0)+1)}));t.EventEmitter.subscribe(this.getEventObject(),"onReady",(function(e){var i=e.data;if(a.jobs.size<=0||!a.jobs.has(i)){return}var n=a.jobs.get(i);if(n<=1){a.jobs["delete"](i);if(a.jobs.size<=0){t.EventEmitter.emit(a.getEventObject(),"onLHEIsReady")}}else{a.jobs.set(i,--n)}}))}babelHelpers.createClass(e,[{key:"setEditorParams",value:function e(t){this.editorParams=Object.assign(this.editorParams,t)}},{key:"bindEvents",value:function e(){var i=this;var n=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;this.events={};[["OnEditorInitedBefore",this.OnEditorInitedBefore.bind(this)],["OnCreateIframeAfter",this.OnCreateIframeAfter.bind(this)],["OnEditorInitedAfter",this.OnEditorInitedAfter.bind(this)]].forEach((function(e){var t=babelHelpers.slicedToArray(e,2),r=t[0],a=t[1];if(!n){i.events[r]=function(e){if(e.id===i.getId()){
//!it important to use deprecated eventEmitter
BX.removeCustomEvent(r,i.events[r]);delete i.events[r];a(e)}};//!it important to use deprecated eventEmitter
BX.addCustomEvent(r,i.events[r])}else{a(n)}}));t.EventEmitter.subscribe(this.getEventObject(),"OnShowLHE",this.OnShowLHE.bind(this));t.EventEmitter.subscribe(this.getEventObject(),"OnButtonClick",this.OnButtonClick.bind(this));t.EventEmitter.subscribe(this.getEventObject(),"OnParserRegister",(function(e){var t=e.data;i.addParser(t)}));t.EventEmitter.subscribe(this.getEventObject(),"OnGetHTMLEditor",(function(e){var t=e.data;t.htmlEditor=i.getEditor()}));t.EventEmitter.subscribe(this.getEventObject(),"OnInsertContent",(function(e){var t=babelHelpers.slicedToArray(e.data,2),n=t[0],r=t[1];i.insertContent(n,r)}));t.EventEmitter.subscribe(this.getEventObject(),"OnAddButton",(function(e){var t=babelHelpers.slicedToArray(e.data,2),n=t[0],r=t[1];i.getToolbar().insertAfter(n,r)}));B(this)}},{key:"getId",value:function e(){return this.id}},{key:"setEditor",value:function i(n){var a=this;if(this.htmlEditor===n){return}this.htmlEditor=n;n.formID=this.getFormId();t.EventEmitter.subscribe(n,"OnCtrlEnter",(function(){n.SaveContent();if(r.Type.isFunction(a.editorParams.ctrlEnterHandler)){a.editorParams.ctrlEnterHandler()}else if(r.Type.isStringFilled(a.editorParams.ctrlEnterHandler)&&window[a.editorParams.ctrlEnterHandler]){window[a.editorParams.ctrlEnterHandler]()}else if(document.forms[a.getFormId()]){BX.submit(document.forms[a.getFormId()])}}));this.editorParams["height"]=n.config["height"];console.groupCollapsed("main.post.form: parsers: ",this.getId());this.editorParams.parsers.forEach((function(e){var t=v(e,a,n);if(t){console.groupCollapsed(e);console.log(t);if(t.hasButton()){n.AddButton(t.getButton())}n.AddParser(t.getParser());console.groupEnd(e)}}));console.groupEnd("main.post.form: parsers: ",this.getId());t.EventEmitter.subscribe(n,"OnImageDataUriHandle",(function(e){var i=babelHelpers.slicedToArray(e.compatData,2),r=i[0],o=i[1];var s=BX.UploaderUtils.dataURLToBlob(o.src);if(s&&s.size>0&&s.type.indexOf("image/")===0){t.EventEmitter.emit(a.getEventObject(),"onShowControllers","show");s.name=s.name||o.title||"image."+s.type.substr(6);s.referrerToEditor=o;t.EventEmitter.emit(a.getEventObject(),"OnImageHasCaught",new t.BaseEvent({data:s})).forEach((function(e){e.then((function(e){var i=e.image,r=e.html;t.EventEmitter.emit(n,"OnImageDataUriCaughtUploaded",new t.BaseEvent({compatData:[o,i,{replacement:r}]}))}))["catch"]((function(){t.EventEmitter.emit(n,"OnImageDataUriCaughtFailed",new t.BaseEvent({compatData:[o]}))}))}))}}));t.EventEmitter.subscribe(t.EventEmitter.GLOBAL_TARGET,"onAddVideoMessage",(function(e){var i=babelHelpers.slicedToArray(e.compatData,2),n=i[0],r=i[1];if(!r||a.getFormId()!==r){return}t.EventEmitter.emit(a.getEventObject(),"onShowControllers","show");t.EventEmitter.emit(a.getEventObject(),"OnVideoHasCaught",new t.BaseEvent({data:n}))}));(function(){var i=BX("micro"+(a.name||a.id));var n=false;var r=0;var o=function e(t){t.preventDefault();t.stopPropagation();if(r>0){clearTimeout(r);r=0}if(n===true){return}var o=t&&t["dataTransfer"]&&t["dataTransfer"]["types"]&&t["dataTransfer"]["types"].indexOf("Files")>=0;if(o){n=true;a.getContainer().classList.add("feed-add-post-dnd-over");if(i){i.classList.add("feed-add-post-micro-dnd-ready")}}return true};var s=function e(t){t.preventDefault();t.stopPropagation();if(r>0){clearTimeout(r)}r=setTimeout((function(){n=false;a.getContainer().classList.remove("feed-add-post-dnd-over");if(i){i.classList.remove("feed-add-post-micro-dnd-ready")}}),100);return false};var l=function e(i){s(i);if(i&&i["dataTransfer"]&&i["dataTransfer"]["types"]&&i["dataTransfer"]["types"].indexOf("Files")>=0&&i["dataTransfer"]["files"]&&i["dataTransfer"]["files"].length>0){t.EventEmitter.emit(a.getEventObject(),"OnShowLHE",new t.BaseEvent({compatData:["justShow",{onShowControllers:"show"}]}));t.EventEmitter.emit(a.getEventObject(),"onFilesHaveCaught",new t.BaseEvent({data:i["dataTransfer"]["files"]}))}return false};a.getContainer().addEventListener("dragover",o);a.getContainer().addEventListener("dragenter",o);a.getContainer().addEventListener("dragleave",s);a.getContainer().addEventListener("dragexit",s);a.getContainer().addEventListener("drop",l);a.getContainer().setAttribute("dropzone","copy f:*/*");if(!document.body.hasAttribute("dropzone")){document.body.setAttribute("dropzone","copy f:*/*");document.body.addEventListener("dragover",(function(e){e.preventDefault();e.stopPropagation();return true}));document.body.addEventListener("drop",function(i){i.preventDefault();i.stopPropagation();if(i&&i["dataTransfer"]&&i["dataTransfer"]["types"]&&i["dataTransfer"]["types"].indexOf("Files")>=0&&i["dataTransfer"]["files"]&&i["dataTransfer"]["files"].length>0){var n;var r;var a=X(this.constructor,e,D).keys();while((r=a.next())&&r.done!==true&&r.value){n=r.value}if(n){t.EventEmitter.emit(n.getEventObject(),"OnShowLHE",new t.BaseEvent({compatData:["justShow",{onShowControllers:"show"}]}));t.EventEmitter.emit(n.getEventObject(),"onFilesHaveCaught",new t.BaseEvent({data:i["dataTransfer"]["files"]}))}}return false}.bind(a))}if(i){i.addEventListener("dragenter",(function(e){o(e);t.EventEmitter.emit(a.getEventObject(),"OnShowLHE",new t.BaseEvent({compatData:["justShow",{onShowControllers:"show"}]}))}))}t.EventEmitter.subscribe(a.getEditor(),"OnIframeDrop",(function(e){var t=babelHelpers.slicedToArray(e.data,1),i=t[0];return l(i)}));t.EventEmitter.subscribe(a.getEditor(),"OnIframeDragOver",(function(e){var t=babelHelpers.slicedToArray(e.data,1),i=t[0];return o(i)}));t.EventEmitter.subscribe(a.getEditor(),"OnIframeDragLeave",(function(e){var t=babelHelpers.slicedToArray(e.data,1),i=t[0];return s(i)}))})();t.EventEmitter.subscribe(n,"OnInsertContent",(function(e){var t=babelHelpers.slicedToArray(e.data,2),i=t[0],n=t[1];a.insertContent(i,n)}));g(this,n,this.editorParams);y(n,this.editorParams);w(this,n);E(n,BX(this.getFormId()));I(this,n);t.EventEmitter.subscribe(this.getEventObject(),"OnAfterShowLHE",(function(){a.getEditor().AllowBeforeUnloadHandler()}));t.EventEmitter.subscribe(this.getEventObject(),"OnAfterHideLHE",(function(){x.hidePopup();a.getEditor().DenyBeforeUnloadHandler()}));t.EventEmitter.subscribe(n,"OnIframeClick",(function(){var e=new MouseEvent("click",{bubbles:true,cancelable:true,view:window});n.iframeView.container.dispatchEvent(e)}))}},{key:"getEditor",value:function e(){return this.htmlEditor}},{key:"getFormId",value:function e(){return this.formId}},{key:"getEventObject",value:function e(){return this.eventNode}},{key:"getContainer",value:function e(){return this.eventNode}},{key:"getToolbar",value:function e(){return this.toolbar}},{key:"OnEditorInitedBefore",value:function e(t){this.setEditor(t)}},{key:"OnCreateIframeAfter",value:function e(){if(this.editorIsLoaded!==true){this.editorIsLoaded=true;this.exec();t.EventEmitter.emit(this,"OnEditorIsLoaded",[])}}},{key:"OnEditorInitedAfter",value:function e(i){if(!this.editorParams.lazyLoad){t.EventEmitter.emit(this.getEventObject(),"OnShowLHE",new t.BaseEvent({compatData:["justShow",i,false]}))}if(i.sandbox&&i.sandbox.inited){this.OnCreateIframeAfter()}}},{key:"addParser",value:function e(t){var i=this;this.exec((function(){t.init(i.getEditor());i.getEditor().AddParser({name:t.id,obj:{Parse:function e(i,n){return t.parse(n)},UnParse:t.unparse}});if(!i["addParserAfterDebounced"]){i.addParserAfterDebounced=r.Runtime.debounce((function(){i.getEditor().SetContent(i.getEditor().GetContent().replace(/&#91;/gi,"[").replace(/&#93;/gi,"]"),true)}),100)}i.addParserAfterDebounced()}))}},{key:"insertContent",value:function e(t){var i=this;var n=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;this.exec((function(){var e=i.getEditor().GetViewMode();if(e==="wysiwyg"){i.getEditor().InsertHtml(n||t);setTimeout(i.getEditor().AutoResizeSceleton.bind(i.getEditor()),500);setTimeout(i.getEditor().AutoResizeSceleton.bind(i.getEditor()),1e3)}else{i.getEditor().textareaView.Focus();if(!i.getEditor().bbCode){var r=i.getEditor().GetIframeDoc();var a=r.createElement("DIV");a.style.display="none";a.innerHTML=t;r.body.appendChild(a);t=i.getEditor().Parse(t,true,false);a.parentNode.removeChild(a)}i.getEditor().textareaView.WrapWith("","",t)}}))}},{key:"reinit",value:function e(i,n){var a="hide";if(r.Type.isPlainObject(n)&&Object.values(n).length){Object.values(n).forEach((function(e){if(e&&e["VALUE"]){a="show"}}))}t.EventEmitter.emit(this.getEventObject(),"onShowControllers",a);t.EventEmitter.emit(this.getEventObject(),"onReinitializeBefore",[i,n]);this.getEditor().CheckAndReInit(r.Type.isString(i)?i:"");BX.onCustomEvent(this.getEditor(),"onReinitialize",[this,i,n]);if(this.editorParams["height"]){this.oEditor.SetConfigHeight(this.editorParams["height"]);this.oEditor.ResizeSceleton()}}},{key:"OnShowLHE",value:function i(n){var a=this;var o=n.data,s=n.compatData;var l=o||s,d=babelHelpers.slicedToArray(l,3),c=d[0],u=d[1],f=d[2];if(!this.getEditor()&&window["BXHtmlEditor"]){window["BXHtmlEditor"].Get(this.getId()).Init()}c=c===false||c==="hide"||c==="justShow"?c:true;var p=BX("micro"+(this.name||this.id));if(p){p.style.display=c===true||c==="justShow"?"none":"block"}if(c==="hide"){X(this.constructor,e,D)["delete"](this);t.EventEmitter.emit(this.getEventObject(),"OnBeforeHideLHE");if(this.getContainer().style.display==="none"){t.EventEmitter.emit(this.getEventObject(),"OnAfterHideLHE");t.EventEmitter.emit(this.getEventObject(),"onShowControllers","hide")}else{new BX["easing"]({duration:200,start:{opacity:100,height:this.getContainer().scrollHeight},finish:{opacity:0,height:20},transition:BX.easing.makeEaseOut(BX.easing.transitions.quad),step:function e(t){a.getContainer().style.height=t.height+"px";a.getContainer().style.opacity=t.opacity/100},complete:function e(){a.getContainer().style.cssText="";a.getContainer().style.display="none";t.EventEmitter.emit(a.getEventObject(),"OnAfterHideLHE");t.EventEmitter.emit(a.getEventObject(),"onShowControllers","hide")}}).animate()}}else if(c){X(this.constructor,e,D).set(this);this.formEntityType=r.Type.isArray(f)&&r.Type.isStringFilled(f[0])&&f[0].match(/^TASK_(\d+)$/i)?"task":null;if(u&&r.Type.isPlainObject(u)){if(u["onShowControllers"]){t.EventEmitter.emit(this.getEventObject(),"onShowControllers",u["onShowControllers"])}}t.EventEmitter.emit(this.getEventObject(),"OnBeforeShowLHE");if(c==="justShow"||this.getContainer().style.display==="block"){this.getContainer().style.display="block";t.EventEmitter.emit(this.getEventObject(),"OnAfterShowLHE");if(u!==false){this.getEditor().Focus()}}else{r.Dom.adjust(this.getContainer(),{style:{display:"block",overflow:"hidden",height:"20px",opacity:.1}});new BX["easing"]({duration:200,start:{opacity:10,height:20},finish:{opacity:100,height:this.getContainer().scrollHeight},transition:BX.easing.makeEaseOut(BX.easing.transitions.quad),step:function e(t){a.getContainer().style.height=t.height+"px";a.getContainer().style.opacity=t.opacity/100},complete:function e(){t.EventEmitter.emit(a.getEventObject(),"OnAfterShowLHE");a.getEditor().Focus();a.getContainer().style.cssText=""}}).animate()}}else{X(this.constructor,e,D)["delete"](this);t.EventEmitter.emit(this.getEventObject(),"OnBeforeHideLHE");t.EventEmitter.emit(this.getEventObject(),"onShowControllers","hide");this.getContainer().style.display="none";t.EventEmitter.emit(this.getEventObject(),"OnAfterHideLHE")}}},{key:"OnButtonClick",value:function e(i){var n=babelHelpers.slicedToArray(i.data,1),r=n[0];if(r!=="cancel"){var a={result:true};t.EventEmitter.emit(this.getEventObject(),"OnClickBeforeSubmit",new t.BaseEvent({compatData:[this,a]}));if(a["result"]!==false){t.EventEmitter.emit(this.getEventObject(),"OnClickSubmit",new t.BaseEvent({compatData:[this]}))}}else{t.EventEmitter.emit(this.getEventObject(),"OnClickCancel",new t.BaseEvent({compatData:[this]}));t.EventEmitter.emit(this.getEventObject(),"OnShowLHE",new t.BaseEvent({compatData:["hide"]}))}}},{key:"exec",value:function e(t,i){if(typeof t=="function"){this.actionQueue.push([t,i])}if(this.editorIsLoaded===true){var n;while((n=this.actionQueue.shift())&&n){n[0].apply(this,n[1])}}}},{key:"showPanelEditor",value:function e(){g(this,this.getEditor(),{})}},{key:"getContent",value:function e(){return this.oEditor?this.oEditor.GetContent():""}},{key:"setContent",value:function e(t){if(this.getEditor()){this.getEditor().SetContent(t)}}},{key:"controllerInit",value:function e(i){t.EventEmitter.emit(this.getEventObject(),"onShowControllers",i==="hide"?"hide":"show")}},{key:"isReady",get:function e(){return this.editorIsLoaded}},{key:"oEditor",get:function e(){return this.getEditor()}},{key:"oEditorId",get:function e(){return this.getId()}},{key:"formID",get:function e(){return this.getFormId()}},{key:"params",get:function e(){return{formID:this.getFormId()}}},{key:"controllers",get:function e(){var i=new t.BaseEvent;var n={};i.setData(n);t.EventEmitter.emit(this.getEventObject(),"onCollectControllers",i);var a={};Object.keys(n).forEach((function(e){a[e]=Object.assign({},n[e]);a[e]["values"]={};if(r.Type.isArray(n[e]["values"])){n[e]["values"].forEach((function(t){a[e]["values"][t]={id:t}}))}else if(r.Type.isPlainObject(n[e]["values"])){a[e]["values"]=Object.assign({},n[e]["values"])}}));return a}},{key:"arFiles",get:function e(){var i=new t.BaseEvent;var n={};i.setData(n);t.EventEmitter.emit(this.getEventObject(),"onCollectControllers",i);var r={};Object.keys(n).forEach((function(e){if(n[e]["values"]){n[e]["values"].forEach((function(t){r[t]=[e]}))}}));return r}}]);return e}();babelHelpers.defineProperty(A,"repo",new Map);var D={writable:true,value:new Map};window["LHEPostForm"]={getEditor:function e(t){return window["BXHtmlEditor"]?window["BXHtmlEditor"].Get(babelHelpers["typeof"](t)=="object"?t.id:t):null},getHandler:function e(t){var i=r.Type.isStringFilled(t)?t:t.id;return A.repo.get(i)},getHandlerByFormId:function e(t){var i=null;A.repo.forEach((function(e){if(e.getFormId()===t){i=e}}));return i},reinitData:function e(t,i,n){var a={};if(!r.Type.isPlainObject(n)){n={}}Object.entries(n).forEach((function(e){var t=babelHelpers.slicedToArray(e,2),i=t[0],n=t[1];if(r.Type.isPlainObject(n)&&n["USER_TYPE_ID"]&&n["VALUE"]&&Object.values(n["VALUE"]).length>0){a[i]=n}}));var o=this.getHandler(t);if(o&&(o.isReady||r.Type.isStringFilled(i)||Object.values(a).length>0)){o.exec(o.reinit,[i,a])}return false},reinitDataBefore:function e(i){var n=A.repo.get(i);if(n&&n.getEventObject()){t.EventEmitter.emit(n.getEventObject(),"onReinitializeBefore",[n])}}};e.PostForm=A;e.PostFormTasksLimit=x})(this.BX.Main=this.BX.Main||{},BX.Event,BX,BX.Main,BX);(function(){if(window["BXPostFormTags"])return;var e={selector:{},mentionParams:{}};window.BXPostFormTags=function(e,t){this.popup=null;this.formID=e;this.buttonID=t;this.sharpButton=null;this.addNewLink=null;this.tagsArea=null;this.hiddenField=null;this.popupContent=null;BX.ready(BX.proxy(this.init,this))};window.BXPostFormTags.prototype.init=function(){this.sharpButton=BX(this.buttonID);this.addNewLink=BX("post-tags-add-new-"+this.formID);this.tagsArea=BX("post-tags-block-"+this.formID);this.tagsContainer=BX("post-tags-container-"+this.formID);this.hiddenField=BX("post-tags-hidden-"+this.formID);this.popupContent=BX("post-tags-popup-content-"+this.formID);this.popupInput=BX.findChild(this.popupContent,{tag:"input"});var e=BX.findChildren(this.tagsContainer,{className:"feed-add-post-del-but"},true);for(var t=0,i=e.length;t<i;t++){BX.bind(e[t],"click",BX.proxy(this.onTagDelete,{obj:this,tagBox:e[t].parentNode,tagValue:e[t].parentNode.getAttribute("data-tag")}))}BX.bind(this.sharpButton,"click",BX.proxy(this.onButtonClick,this));BX.bind(this.addNewLink,"click",BX.proxy(this.onAddNewClick,this))};window.BXPostFormTags.prototype.onTagDelete=function(){BX.remove(this.tagBox);this.obj.hiddenField.value=this.obj.hiddenField.value.replace(this.tagValue+",","").replace("  "," ")};window.BXPostFormTags.prototype.show=function(){if(this.popup===null){this.popup=new BX.PopupWindow("bx-post-tag-popup",this.addNewLink,{content:this.popupContent,lightShadow:false,offsetTop:8,offsetLeft:10,autoHide:true,angle:true,closeByEsc:true,zIndex:-840,buttons:[new BX.PopupWindowButton({text:BX.message("TAG_ADD"),events:{click:BX.proxy(this.onTagAdd,this)}})]});BX.bind(this.popupInput,"keydown",BX.proxy(this.onKeyPress,this));BX.bind(this.popupInput,"keyup",BX.proxy(this.onKeyPress,this))}this.popup.show();BX.focus(this.popupInput)};window.BXPostFormTags.prototype.addTag=function(e){var t=BX.type.isNotEmptyString(e)?e.split(","):this.popupInput.value.split(",");var i=[];for(var n=0;n<t.length;n++){var r=BX.util.trim(t[n]);if(r.length>0){var a=this.hiddenField.value.split(",");if(!BX.util.in_array(r,a)){var o;var s=BX.create("span",{children:[o=BX.create("span",{attrs:{class:"feed-add-post-del-but"}})],attrs:{class:"feed-add-post-tags"}});s.insertBefore(document.createTextNode(r),o);this.tagsContainer.insertBefore(s,this.addNewLink);BX.bind(o,"click",BX.proxy(this.onTagDelete,{obj:this,tagBox:s,tagValue:r}));this.hiddenField.value+=r+",";i.push(r)}}}return i};window.BXPostFormTags.prototype.onTagAdd=function(){this.addTag();this.popupInput.value="";this.popup.close()};window.BXPostFormTags.prototype.onAddNewClick=function(e){e=e||window.event;this.show();BX.PreventDefault(e)};window.BXPostFormTags.prototype.onButtonClick=function(e){e=e||window.event;BX.show(this.tagsArea);this.show();BX.PreventDefault(e)};window.BXPostFormTags.prototype.onKeyPress=function(e){e=e||window.event;var t=e.keyCode?e.keyCode:e.which?e.which:null;if(t==13){setTimeout(BX.proxy(this.onTagAdd,this),0)}};window.BXPostFormImportant=function(e,t,i){if(i){this.formID=e;this.buttonID=t;this.inputName=i;this.fireButton=null;this.activeBlock=null;this.hiddenField=null;BX.ready(BX.proxy(this.init,this))}return false};window.BXPostFormImportant.prototype.init=function(){this.fireButton=BX(this.buttonID);this.activeBlock=BX(this.buttonID+"-active");var e=BX(this.formID);if(e){this.hiddenField=e[this.inputName];if(this.hiddenField&&this.hiddenField.value==1){this.showActive()}}BX.bind(this.fireButton,"click",BX.proxy((function(e){e=e||window.event;this.showActive();BX.PreventDefault(e)}),this));BX.bind(this.activeBlock,"click",BX.proxy((function(e){e=e||window.event;this.hideActive();BX.PreventDefault(e)}),this))};window.BXPostFormImportant.prototype.showActive=function(e){BX.hide(this.fireButton);BX.show(this.activeBlock,"inline-block");if(this.hiddenField){this.hiddenField.value=1}return false};window.BXPostFormImportant.prototype.hideActive=function(e){BX.hide(this.activeBlock);BX.show(this.fireButton,"inline-block");if(this.hiddenField){this.hiddenField.value=0}return false};var t=null;window.MPFbuttonShowWait=function(e){if(e&&!BX.type.isElementNode(e)){e=null}e=e||this;e=e?e.tagName=="A"?e:e.parentNode:e;if(e){BX.addClass(e,"ui-btn-clock");t=e;BX.defer((function(){e.disabled=true}))()}};var i={listen:false,plus:false,text:"",bSearch:false,node:null,mode:null};BX.addCustomEvent(window,"onInitialized",(function(e){if(e&&e.eventNode){BX.onCustomEvent(e.eventNode,"OnClickCancel",(function(){i.node=null}))}}));BX.addCustomEvent(window,"BX.MPF.MentionSelector:open",(function(t){var i=BX.Type.isStringFilled(t.formId)?t.formId:"";if(!BX.Type.isStringFilled(i)||BX.Type.isUndefined(e.mentionParams[i])){return}var n=BX.Type.isDomNode(t.bindNode)?t.bindNode:null;var r=BX.type.isNotEmptyObject(t.bindPosition)?t.bindPosition:null;var a=window.MPFgetSelectorId("bx-mention-"+i+"-id")+(n?"-withsearch":"");var o=BX.UI.EntitySelector.Dialog.getById(a);if(!o){window.MPFcreateSelectorDialog({formId:i,selectorId:a,enableSearch:!!n,params:e.mentionParams[i]});o=BX.UI.EntitySelector.Dialog.getById(a)}if(!o){return}o.deselectAll();o.search("");o.show();var s={};if(BX.Type.isDomNode(n)){o.focusSearch();o.popup.setBindElement(n);s.position="top"}else if(BX.type.isNotEmptyObject(r)){r.top-=5;o.popup.setBindElement(r)}o.popup.adjustPosition(s)}));window.onKeyDownHandler=function(e,t,r){var a=e.keyCode;if(!window["BXfpdStopMent"+r]){return true}var o=window.MPFgetSelectorId("bx-mention-"+r+"-id");if(a===t.KEY_CODES["backspace"]&&i.node){var s=BX.util.trim(t.util.GetTextContent(i.node));if(s==="+"||s==="@"||i.mode=="button"&&s.length==1){window["BXfpdStopMent"+r]()}else if(i.mode=="button"&&s.length==1){window["BXfpdStopMent"+r]()}}if(BX.util.in_array(a,[107,187])||(e.shiftKey||e.modifiers>3)&&BX.util.in_array(a,[50,43,61])||e.altKey&&BX.util.in_array(a,[76])||e.altKey&&e.ctrlKey&&BX.util.in_array(a,[81])&&e.key==="@"||e.altKey&&BX.util.in_array(a,[71,81])&&e.key==="@"||e.altKey&&BX.util.in_array(a,[50])&&e.key==="@"||BX.Type.isFunction(e.getModifierState)&&!!e.getModifierState("AltGraph")&&BX.util.in_array(a,[81,50,48])&&!BX.Type.isUndefined(e.key)&&e.key==="@"||BX.util.in_array(a,[192])&&e.key==="@"){setTimeout((function(){var e=t.selection.GetRange();var a=t.GetIframeDoc();var s=e?e.endContainer.textContent:"";var l=s?s.slice(e.endOffset-1,e.endOffset):"";var d=s?s.slice(e.endOffset-2,e.endOffset-1):"";if((l=="@"||l=="+")&&(!d||BX.util.in_array(d,["+","@",",","("])||d.length==1&&BX.util.trim(d)==="")){i.listen=true;i.listenFlag=true;i.text="";i.leaveContent=true;i.mode="plus";e.setStart(e.endContainer,e.endOffset-1);e.setEnd(e.endContainer,e.endOffset);t.selection.SetSelection(e);i.node=BX.create("SPAN",{props:{id:"bx-mention-node"}},a);t.selection.Surround(i.node,e);e.setStart(i.node,1);e.setEnd(i.node,1);t.selection.SetSelection(e);if(BX.Type.isStringFilled(o)){BX.onCustomEvent(window,"BX.MPF.MentionSelector:open",[{formId:r,bindPosition:n(i.node,t)}])}}}),10)}if(i.listen){var l=null;var d=BX.Type.isStringFilled(o)?BX.UI.EntitySelector.Dialog.getById(o):null;if(d&&d.getActiveTab()){l=d.getActiveTab().getId()}var c=null;switch(a){case t.KEY_CODES.enter:c="Enter";break;case 9:c="Tab";break;case t.KEY_CODES.up:c="ArrowUp";break;case t.KEY_CODES.down:c="ArrowDown";break;case t.KEY_CODES.left:if(l==="departments"){c="ArrowLeft"}break;case t.KEY_CODES.right:if(l==="departments"){c="ArrowRight"}break}if(c){var u=new KeyboardEvent("keydown",{key:c,keyCode:a,bubbles:true,cancelable:true,view:window});if(!document.dispatchEvent(u)){t.iframeKeyDownPreventDefault=true;e.stopPropagation();e.preventDefault()}}}if(!i.listen&&i.listenFlag&&a===t.KEY_CODES["enter"]){var f=t.selection.GetRange();if(f.collapsed){var p=f.endContainer;var h=t.GetIframeDoc();if(p){if(p.className!=="bxhtmled-metion"){p=BX.findParent(p,(function(e){return e.className=="bxhtmled-metion"}),h.body)}if(p&&p.className=="bxhtmled-metion"){t.selection.SetAfter(p)}}}}};window.onKeyUpHandler=function(e,t,n){var r=e.keyCode;var a;var o;if(!window["BXfpdStopMent"+n]){return true}if(i.listen===true){if(r==t.KEY_CODES.escape){var s=new KeyboardEvent("keyup",{key:"Escape",keyCode:r,bubbles:true,cancelable:true,view:window});if(!document.dispatchEvent(s)){e.stopPropagation();e.preventDefault()}window["BXfpdStopMent"+n]()}else if(r!==t.KEY_CODES.enter&&r!==t.KEY_CODES.left&&r!==t.KEY_CODES.right&&r!==t.KEY_CODES.up&&r!==t.KEY_CODES.down){if(BX(i.node)){o=BX.util.trim(t.util.GetTextContent(i.node));var l=o;o=o.replace(/^[\+@]*/,"");i.bSearch=BX.Type.isStringFilled(o);var d=window.MPFgetSelectorId("bx-mention-"+n+"-id");var c=BX.UI.EntitySelector.Dialog.getById(d);if(BX.Type.isStringFilled(o)&&c){c.search(o)}if(i.leaveContent&&i._lastText){if(l===""){window["BXfpdStopMent"+n]()}else if(l!==""&&o===""){i.bSearch=false;if(c){c.search("")}}}i.lastText=o;i._lastText=l}else{window["BXfpdStopMent"+n]()}}}else{if(!e.shiftKey&&(r===t.KEY_CODES["space"]||r===t.KEY_CODES["escape"]||r===188||r===190)){a=t.selection.GetRange();if(a.collapsed){var u=a.endContainer;var f=t.GetIframeDoc();if(u){if(u.className!=="bxhtmled-metion"){u=BX.findParent(u,(function(e){return e.className=="bxhtmled-metion"}),f.body)}if(u&&u.className=="bxhtmled-metion"){o=t.util.GetTextContent(u);var p=o.match(/[\s\.\,]$/);if(p||r===t.KEY_CODES["escape"]){u.innerHTML=o.replace(/[\s\.\,]$/,"");var h=BX.create("SPAN",{html:p||t.INVISIBLE_SPACE},f);t.util.InsertAfter(h,u);t.selection.SetAfter(h)}}}}}}};window.onTextareaKeyDownHandler=function(e,t,n){var r=e.keyCode;if(i.listen&&r==t.KEY_CODES.enter){t.textareaKeyDownPreventDefault=true;e.stopPropagation();e.preventDefault()}};window.onTextareaKeyUpHandler=function(e,t,n){var r=null;var a="";var o=e.keyCode;var s=window.MPFgetSelectorId("bx-mention-"+n+"-id");if(i.listen===true){if(o==27){window["BXfpdStopMent"+n]()}else if(o!==13){a=t.textareaView.GetValue(false);r=t.textareaView.GetCursorPosition();var l="";var d="";if(a.indexOf("+")!==-1||a.indexOf("@")!==-1){var c=a.substr(0,r);var u=Math.max(c.lastIndexOf("+"),c.lastIndexOf("@"));if(u>=0){l=c.substr(u);d=l;l=l.replace(/^[\+@]*/,"");i.bSearch=BX.Type.isStringFilled(l);var f=BX.UI.EntitySelector.Dialog.getById(s);if(BX.Type.isStringFilled(l)&&f){f.search(l)}}}if(i._lastText){if(d===""){window["BXfpdStopMent"+n]()}else if(d!==""&&l===""){i.bSearch=false;if(f){f.search("")}}}i.lastText=l;i._lastText=d}}else{if(o==16){var p=this;this.shiftPressed=true;if(this.shiftTimeout){this.shiftTimeout=clearTimeout(this.shiftTimeout)}this.shiftTimeout=setTimeout((function(){p.shiftPressed=false}),100)}if(o==107||(e.shiftKey||e.modifiers>3||this.shiftPressed)&&BX.util.in_array(o,[187,50,107,43,61])){r=t.textareaView.element.selectionStart;if(r>0){a=t.textareaView.element.value;var h=a.substr(r-1,1);if(h&&(h==="+"||h==="@")){i.listen=true;i.listenFlag=true;i.text="";i.textarea=true;i.bSearch=false;i.mode="plus";BX.onCustomEvent(window,"BX.MPF.MentionSelector:open",[{formId:n,bindPosition:BX.pos(document.getElementById("bx-b-mention-"+n))}])}}}}};var n=function(e,t){var i=BX.pos(e);var n=BX.pos(t.dom.areaCont);var r=BX.GetWindowScrollPos(t.GetIframeDoc());var a=n.top+i.bottom-r.scrollTop+2;var o=n.left+i.right-r.scrollLeft;return{top:a,left:o}};window.BxInsertMention=function(e){var t=e.item;var r=e.type;var a=e.formID;var o=e.editorId;var s=e.bNeedComa;var l=LHEPostForm.getEditor(o);var d;if((r==="user"||r==="project"||r==="department")&&t&&t.entityId>0&&l){if(l.GetViewMode()=="wysiwyg"){var c=l.GetIframeDoc();var u=l.selection.GetRange();var f=BX.create("SPAN",{props:{className:"bxhtmled-metion"},text:BX.util.htmlspecialcharsback(t.name)},c);d=BX.create("SPAN",{html:s?",&nbsp;":"&nbsp;"},c);var p={tag:"postuser",params:{value:t.entityId}};switch(r){case"project":p.projectId=t.entityId;p.projectName=t.name;break;case"department":p.departmentId=t.entityId;p.departmentName=t.name;break;default:p.userId=t.entityId;p.userName=t.name}l.SetBxTag(f,p);if(BX(i.node)&&i.node.parentNode){l.util.ReplaceNode(i.node,f)}else{l.selection.InsertNode(f,u)}if(f&&f.parentNode){var h=BX.findParent(f,{className:"bxhtmled-metion"},c.body);if(h){l.util.InsertAfter(f,h)}}if(f&&f.parentNode){l.util.InsertAfter(d,f);l.selection.SetAfter(d)}}else if(l.GetViewMode()=="code"&&l.bbCode){l.textareaView.Focus();var b=l.textareaView.GetValue(false);var m=l.textareaView.GetCursorPosition();var v=b.substr(0,m);var E=Math.max(v.lastIndexOf("+"),v.lastIndexOf("@"));if(E>=0&&m>E){l.textareaView.SetValue(b.substr(0,E)+b.substr(m));l.textareaView.element.setSelectionRange(E,E)}var g="";switch(r){case"user":g="USER";break;case"project":g="PROJECT";break;case"department":g="DEPARTMENT";break;default:}l.textareaView.WrapWith(false,false,"["+g+"="+t.entityId+"]"+t.name+"[/"+g+"]"+(s?", ":" "))}if(e.fireAddEvent===true){BX.onCustomEvent(window,"onMentionAdd",[t,r])}if(window["BXfpdStopMent"+a]){window["BXfpdStopMent"+a]()}i["text"]="";if(l.GetViewMode()=="wysiwyg"){l.Focus();l.selection.SetAfter(d)}var y=LHEPostForm.getHandler(o);if(y&&y.formEntityType==="task"&&y.editorParams.tasksLimitExceeded){BX.Main.PostFormTasksLimit.showPopup({bindPosition:n(i.node,l)})}}};window.MPFgetSelectorId=function(e){var t=false;var i=BX(e);if(!i){return t}t=i.getAttribute("data-bx-selector-id");return t};window.MPFcreateSelectorDialog=function(e){new BX.UI.EntitySelector.Dialog({targetNode:"mpf-mention-"+e.formId,id:e.selectorId,context:"MENTION",multiple:false,enableSearch:e.enableSearch,clearSearchOnSelect:true,hideOnSelect:true,hideByEsc:true,entities:e.params.entities,height:300,width:400,compactView:true,events:{onShow:function(){window.BXfpdOnDialogOpen()},onHide:function(){window.BXfpdOnDialogClose({editorId:e.params.editorId})},"Item:onSelect":function(t){var i=t.getData().item;if(i){window["BXfpdSelectCallbackMent"+e.formId]({item:{name:i.getTitle(),entityId:i.getId()},entityType:i.getEntityId()})}}}})};window.MPFMentionInit=function(t,n){e.mentionParams[t]=n;if(n.initDestination===true){BX.addCustomEvent("onAutoSaveRestoreDestination",(function(e){if(BX.type.isNotEmptyObject(e)&&BX.type.isNotEmptyObject(e.data)&&BX.type.isNotEmptyString(e.data.DEST_DATA)&&BX.type.isNotEmptyString(e.formId)&&e.formId==t&&BX.UI.EntitySelector){var i=JSON.parse(e.data.DEST_DATA);if(!Array.isArray(i)){return}var n=BX.UI.EntitySelector.Dialog.getById("oPostFormLHE_blogPostForm");if(!BX.type.isNotEmptyObject(n)){return}n.preselectedItems=i;n.setPreselectedItems(i)}}));BX.addCustomEvent(window,"onMentionAdd",(function(e,t){var i=BX.UI.EntitySelector.Dialog.getById("oPostFormLHE_blogPostForm");if(!BX.type.isNotEmptyObject(i)){return}var n="";if(t==="user"){if(e.isExtranet==="Y"){n="extranet"}else if(e.isEmail==="Y"){n="email"}else{n="employee"}}else if(t==="project"){if(e.isExtranet==="Y"){n="extranet"}}i.addItem({avatar:e.avatar,customData:{email:BX.Type.isStringFilled(e.email)?e.email:""},entityId:t,entityType:n,id:e.entityId,title:e.name}).select()}))}window["BXfpdSelectCallbackMent"+t]=function(e){window.BxInsertMention({item:e.item,type:e.entityType.toLowerCase(),formID:t,editorId:n.editorId,fireAddEvent:n.initDestination})};window["BXfpdStopMent"+t]=function(){var e=window.MPFgetSelectorId("bx-mention-"+t+"-id");var i=BX.UI.EntitySelector.Dialog.getById(e);if(i){i.hide()}};if(BX(t)){BX.addCustomEvent(BX(t),"OnUCFormAfterShow",(function(e){if(!BX.type.isNotEmptyObject(e)||!BX.type.isArray(e.id)||!BX.Type.isStringFilled(e.id[0])){return}var t=new RegExp("EVENT_(\\d+)","i");if(!t.test(e.id[0])){return}}))}var r=LHEPostForm.getHandlerByFormId(t);if(r){r.exec()}BX.ready((function(){var e=BX("bx-b-mention-"+t);BX.bind(e,"click",(function(r){if(i.listen!==true){var a=LHEPostForm.getEditor(n.editorId);var o=a.GetIframeDoc();if(a.GetViewMode()=="wysiwyg"&&o){i.listen=true;i.listenFlag=true;i.text="";i.leaveContent=false;i.mode="button";var s=a.selection.GetRange();if(BX(i.node)){BX.remove(BX(i.node))}a.InsertHtml('<span id="bx-mention-node">'+a.INVISIBLE_SPACE+"</span>",s);setTimeout((function(){BX.onCustomEvent(window,"BX.MPF.MentionSelector:open",[{formId:t,bindNode:e}]);i.node=o.getElementById("bx-mention-node");if(i.node){s.setStart(i.node,0);if(i.node.firstChild&&i.node.firstChild.nodeType==3&&i.node.firstChild.nodeValue.length>0){s.setEnd(i.node,1)}else{s.setEnd(i.node,0)}a.selection.SetSelection(s)}a.Focus()}),100)}else if(a.GetViewMode()=="code"){i.listen=true;i.listenFlag=true;i.text="";i.leaveContent=false;i.mode="button";setTimeout((function(){BX.onCustomEvent(window,"BX.MPF.MentionSelector:open",[{formId:t,bindNode:e}])}),100)}BX.onCustomEvent(e,"mentionClick")}}))}))};window.BXfpdOnDialogOpen=function(){i.listen=true;i.listenFlag=true};window.BXfpdOnDialogClose=function(e){i.listen=false;setTimeout((function(){i.listenFlag=false;if(!i.listen){var t=LHEPostForm.getEditor(e.editorId);if(t){t.Focus()}}}),100)};MPFEntitySelector=function(t){this.selector=null;this.inputNode=null;this.messages={};if(!BX.Type.isStringFilled(t.id)){return null}if(e.selector[t.id]){return e.selector[t.id]}e.selector[t.id]=this.init(t)};MPFEntitySelector.prototype.init=function(e){if(!BX.type.isPlainObject(e)){e={}}if(!BX.Type.isStringFilled(e.id)||!BX.Type.isStringFilled(e.tagNodeId)||!BX(e.tagNodeId)){return null}if(BX.Type.isStringFilled(e.inputNodeId)&&BX(e.inputNodeId)){this.inputNode=BX(e.inputNodeId)}if(BX.type.isNotEmptyObject(e.messages)){this.messages=e.messages}this.selector=new BX.UI.EntitySelector.TagSelector({id:e.id,dialogOptions:{id:e.id,context:BX.Type.isStringFilled(e.context)?e.context:null,preselectedItems:BX.type.isArray(e.preselectedItems)?e.preselectedItems:[],events:{"Item:onSelect":function(){this.recalcValue(this.selector.getDialog().getSelectedItems())}.bind(this),"Item:onDeselect":function(){this.recalcValue(this.selector.getDialog().getSelectedItems())}.bind(this)},entities:[{id:"meta-user",options:{"all-users":{title:this.messages.allUsersTitle,allowView:BX.type.isBoolean(e.allowToAll)&&e.allowToAll}}},{id:"user",options:{emailUsers:BX.type.isBoolean(e.allowSearchEmailUsers)?e.allowSearchEmailUsers:false,inviteGuestLink:BX.type.isBoolean(e.allowSearchEmailUsers)?e.allowSearchEmailUsers:false,myEmailUsers:true}},{id:"project",options:{features:{blog:["premoderate_post","moderate_post","write_post","full_post"]}}},{id:"department",options:{selectMode:"usersAndDepartments",allowFlatDepartments:false}}]},addButtonCaption:BX.message("BX_FPD_LINK_1"),addButtonCaptionMore:BX.message("BX_FPD_LINK_2")});this.selector.renderTo(document.getElementById(e.tagNodeId));return this.selector};MPFEntitySelector.prototype.recalcValue=function(e){if(!BX.type.isArray(e)||!this.inputNode){return}var t=[];e.forEach((function(e){t.push([e.entityId,e.id])}));this.inputNode.value=JSON.stringify(t)};window.MPFEntitySelector=MPFEntitySelector})()})();
//# sourceMappingURL=script.map.js